module.exports = function($scope,items,$resource,$modalInstance){
    console.log("进来了吗？");
    console.log(items.code);
    $scope.redpacketd={};
    $resource('/api/ac/puc/redPacketProductService/getRedPacketProduct', {}, {}).save({code:items.code}, function(res){
        console.log(res.errcode);
        console.log("传回来的值");
        console.log(res.data.results[0]);
        if(res.errcode==0){
            $scope.redpacketd=res.data.results[0];
            console.log(res.data.results[0].normal_redmoney);
            console.log(res.data.results[0].random_redmoney_start);
            console.log(res.data.results[0].random_redmoney_end);
            console.log(res.data.results[0].consume_redmoney);
            if(res.data.results[0].normal_redmoney!=undefined){
                $scope.redpacketd.money=res.data.results[0].normal_redmoney/100+"元";
            }
            if(res.data.results[0].random_redmoney_start!=undefined && res.data[0].random_redmoney_end!=undefined){
                $scope.redpacketd.money=res.data.results[0].random_redmoney_start/100+"元~"+res.data[0].random_redmoney_end/100+"元";
            }
            if(res.data.results[0].consume_redmoney!=undefined){
                $scope.redpacketd.money=res.data.results[0].consume_redmoney*100+"%";
            }
            //$scope.redpacketd.normal_redmoney=res.data[0].normal_redmoney/100;
                        console.log("zhehehheh");
                        console.log(res.data.results[0].rule);
                        if(res.data.results[0].rule=="n01"){
                            $scope.redpacketd.rule="定额红包";
                        }
                        if(res.data.results[0].rule=="n02"){
                            $scope.redpacketd.rule="随机红包";
                        }
                        if(res.data.results[0].rule=="n03"){
                            $scope.redpacketd.rule="百分比红包";
                        }
                        if(res.data.results[0].rp_type=="01"){
                            $scope.redpacketd.rp_type=" 发放";
                        }
                        if(res.data.results[0].rp_type=="02"){
                            $scope.redpacketd.rp_type=" 自行领取";
                        }
                        if(res.data.results[0].stock_type=="0"){
                            $scope.redpacketd.stock_type="不启用";
                        }
                        if(res.data.results[0].stock_type=="1"){
                            $scope.redpacketd.stock_type="启用";
                        }
                        if(res.data.results[0].max_limit=="-1"){
                            $scope.redpacketd.max_limit="不限制";
                        }
                        if(res.data.results[0].max_limit=="0"){
                            $scope.redpacketd.max_limit="限制";
                        }
                        if(res.data.results[0].type=="01"){
                            $scope.redpacketd.type="商客系统";
                        }
                        if(res.data.results[0].type=="02"){
                            $scope.redpacketd.type="一卡通";
                        }
                        if(res.data.results[0].type=="03"){
                            $scope.redpacketd.type="票务系统";
                        }
                        if(res.data.results[0].status=="0"){
                            $scope.redpacketd.status="草稿";                            
                        }
                        if(res.data.results[0].status=="1"){
                            $scope.redpacketd.status="已上架";   
                        }
                        if(res.data.results[0].status=="2"){
                            $scope.redpacketd.status="已下架";  
                        }
                $scope.redpacketd.create_date=new Date(res.data.results[0].create_date);
                   
            console.log($scope.redpacketd);
        }else{
            alert(res.errmsg);
        }
     });
    $scope.cancel = function () {
            $modalInstance.dismiss('cancel');
    };   
}